﻿/*
 *  PassBag is multi-platform software that securely manage/store passwords
 *  Copyright (C) <2009>  <Hugo Rodrigues PEREIRA>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *	
 *  You can find a copy of the GPLv3 at project <root directory>/gpl.txt
 *
 */

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using PassBag.Logic.Settings;

namespace PassBag.Presentation.Backup {
    public sealed class BackupSetFileDialog {
        public static object SelectFile (string title) {
            SaveFileDialog dlgSave = new SaveFileDialog ();

            if (string.IsNullOrEmpty(title)) {
                title = Properties.Resources.Global_BackupFileDialogTitle;  
            }

            dlgSave.DefaultExt = XmlSettingsManager.Settings.BackupFileExtension;
            dlgSave.Filter = string.Format (PassBag.Properties.Resources.Global_BackupFileDialogFilter, XmlSettingsManager.Settings.BackupFileExtension);
            dlgSave.Title = title;
            dlgSave.FilterIndex = 1;
            dlgSave.CheckFileExists = false;
            dlgSave.CheckPathExists = true;
            dlgSave.OverwritePrompt = false;


            //show dialog and check result
            if (dlgSave.ShowDialog () == DialogResult.OK) {
                return dlgSave.FileName;
            }
            else {
                return DialogResult.Cancel;
            }
        }
    }
}
